import com.beans.*;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App {
    public static void main(String[] args) {
//        //1. 得到上下文对象
//        ApplicationContext context =
//                new ClassPathXmlApplicationContext("spring-config.xml");
//
//        //2. 得到 bean
//       UserController controller =  context.getBean("userController",UserController.class);
//        //3. 使用 bean
//        controller.sayHi();

//        ApplicationContext context =
//                new ClassPathXmlApplicationContext("spring-config.xml");
//
//        User user = context.getBean("FunSet",User.class);
//        System.out.println(user.toString());

        //获取上下文对象
//        ApplicationContext context =
//                new ClassPathXmlApplicationContext("spring-config.xml");
        //取出Bean
       // User user = context.getBean(User.class);
        //User user = (User) context.getBean("user1");
//        User user = (User) context.getBean("FunSet");
//        System.out.println(user.toString());
//
//        //获取上下文对象
//        ApplicationContext context =
//                new ClassPathXmlApplicationContext("spring-config.xml");
//        //取出Bean
//        UserController controller =
//                context.getBean("userController",UserController.class);
//
//        controller.sayHi();

//        //获取上下文对象
//        ApplicationContext context =
//                new ClassPathXmlApplicationContext("spring-config.xml");
//        //取出Bean
//        UserController2 controller =
//                context.getBean(UserController2.class);
//
//        controller.sayHi();

//        //获取上下文对象
//        ApplicationContext context =
//                new ClassPathXmlApplicationContext("spring-config.xml");
//        //取出Bean
//        UserController3 controller =
//                context.getBean(UserController3.class);
//
//        controller.sayHi();

//        //获取上下文对象
//        ApplicationContext context =
//                new ClassPathXmlApplicationContext("spring-config.xml");
//        //取出Bean
//        UserController4 controller =
//                context.getBean(UserController4.class);
//
//        controller.sayHi();


        ApplicationContext context =
                new ClassPathXmlApplicationContext("spring-config.xml");
        BeanScopes1 beanScopes1 = context.getBean(BeanScopes1.class);
        System.out.println(beanScopes1.getUser1());

        BeanScopes2 beanScopes2 = context.getBean(BeanScopes2.class);
        System.out.println(beanScopes2.getUser2());
    }
}
